﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DemoConstructor.Demo4
{
    /// <summary>
    /// Access modifier of Constructor
    /// </summary>
    class Demo4
    {
        public static void RunDemo4()
        {
            SecondClass theSecond = new SecondClass("");
            Console.WriteLine(Environment.NewLine);
            SecondClass theSecond2 = new SecondClass("", "");
        }
    }

    class FirstClass
    {
        private FirstClass()
        {
            Console.WriteLine("Constructor with no param of FirstClass was called.(private)");
        }

        protected FirstClass(string firstParam)
            :this()
        {
            Console.WriteLine("Constructor with one param of FirstClass was called.(protected)");
        }

        public FirstClass(string firstParam, string secondParam)
        {
            Console.WriteLine("Constructor with two params of FirstClass was called.(public)");
        }
    }

    class SecondClass : FirstClass
    {
        /// <summary>
        /// 'DemoConstructor.Demo4.FirstClass.FirstClass()' is inaccessible due to its protection level.
        /// </summary>
        //public SecondClass()
        //    : base()
        //{
        //}

        public SecondClass(string firstParam)
            :base(firstParam)
        {
            Console.WriteLine("Constructor with one param of SecondClass was called. (call base Class)");
        }

        public SecondClass(string firstParam, string secondParam)
            :this(firstParam)            
        {
            Console.WriteLine("Constructor with two params of SecondClass was called. (call this Class)");
        }
    }
}
